package soccer.view;

import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.util.List;
import java.util.Map;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;

public class AddCoachTeamPanel extends JPanel {
	private JTextField textFieldCoachName;
	private JTextField textFieldCoachSurname;
	private JTextField textFieldCoachBirthdate;
	private JTextField textFieldCoachBirthplace;
	private JTextField textFieldCoachAgrement;
	private JTextField textFieldAgrementFinish;
	private JLabel lblCoachName;
	private JLabel lblCoachSurname;
	private JLabel lblCoachBirthdate;
	private JLabel lblCoachBirthplace;
	private JLabel lblTeamSelect;
	private JComboBox comboBox;
	private JPanel panelAgrement;
	private JLabel lblCoachAgrementLabel;
	private JLabel lblCoachAgrementFinish;
	private JButton btnAddCoach;
	private JButton btnBackToAdminOptionsSystem;

	/**
	 * Create the panel.
	 */
	public AddCoachTeamPanel() {
		setLayout(null);
		
		lblCoachName = new JLabel("Coach Name");
		lblCoachName.setBounds(10, 21, 66, 14);
		add(lblCoachName);
		
		textFieldCoachName = new JTextField();
		textFieldCoachName.setBounds(97, 18, 86, 20);
		add(textFieldCoachName);
		textFieldCoachName.setColumns(10);
		
		lblCoachSurname = new JLabel("Coach Surname");
		lblCoachSurname.setBounds(10, 59, 77, 14);
		add(lblCoachSurname);
		
		textFieldCoachSurname = new JTextField();
		textFieldCoachSurname.setBounds(97, 56, 86, 20);
		add(textFieldCoachSurname);
		textFieldCoachSurname.setColumns(10);
		
		lblCoachBirthdate = new JLabel("BirthDate");
		lblCoachBirthdate.setBounds(10, 98, 46, 14);
		add(lblCoachBirthdate);
		
		textFieldCoachBirthdate = new JTextField();
		textFieldCoachBirthdate.setBounds(97, 95, 86, 20);
		add(textFieldCoachBirthdate);
		textFieldCoachBirthdate.setColumns(10);
		
		lblCoachBirthplace = new JLabel("BirthPlace");
		lblCoachBirthplace.setBounds(10, 134, 56, 14);
		add(lblCoachBirthplace);
		
		textFieldCoachBirthplace = new JTextField();
		textFieldCoachBirthplace.setBounds(97, 131, 86, 20);
		add(textFieldCoachBirthplace);
		textFieldCoachBirthplace.setColumns(10);
		
		comboBox = new JComboBox();
		comboBox.setBounds(97, 178, 86, 20);
		comboBox.setMaximumRowCount(12);
		add(comboBox);
		
		lblTeamSelect = new JLabel("Team Select");
		lblTeamSelect.setBounds(10, 181, 66, 14);
		add(lblTeamSelect);
		
		panelAgrement = new JPanel();
		panelAgrement.setBounds(10, 206, 351, 83);
		add(panelAgrement);
		panelAgrement.setLayout(null);
		panelAgrement.setVisible(false);
		
		lblCoachAgrementLabel = new JLabel("Agrement Begin");
		lblCoachAgrementLabel.setBounds(20, 11, 96, 14);
		panelAgrement.add(lblCoachAgrementLabel);
		
		textFieldCoachAgrement = new JTextField();
		textFieldCoachAgrement.setBounds(143, 8, 86, 20);
		panelAgrement.add(textFieldCoachAgrement);
		textFieldCoachAgrement.setColumns(10);
		
		lblCoachAgrementFinish = new JLabel("Agrement Finish");
		lblCoachAgrementFinish.setBounds(20, 45, 77, 14);
		panelAgrement.add(lblCoachAgrementFinish);
		
		textFieldAgrementFinish = new JTextField();
		textFieldAgrementFinish.setBounds(143, 39, 86, 20);
		panelAgrement.add(textFieldAgrementFinish);
		textFieldAgrementFinish.setColumns(10);
		
		btnAddCoach = new JButton("Add Coach");
		btnAddCoach.setBounds(10, 300, 89, 23);
		add(btnAddCoach);
		
		btnBackToAdminOptionsSystem = new JButton("Back to System");
		btnBackToAdminOptionsSystem.setBounds(107, 300, 112, 23);
		add(btnBackToAdminOptionsSystem);

	}
	public void addCoachBackToSystem(ActionListener l){
		btnBackToAdminOptionsSystem.addActionListener(l);
	}
	
	public JButton getBtnBackToAdminOptionsSystem() {
		return btnBackToAdminOptionsSystem;
	}
	public void setBtnBackToAdminOptionsSystem(JButton btnBackToAdminOptionsSystem) {
		this.btnBackToAdminOptionsSystem = btnBackToAdminOptionsSystem;
	}
	public void setVisibleDefaultPanel(){
		panelAgrement.setVisible(false);
		
	}
	public void setVisibleAfterTeamSelectPanel(){
		panelAgrement.setVisible(true);
	}
	public void fillComboBoxWithTeams(List<Map> teamsName){
	    Object[] items = new Object[teamsName.size()+1];
	       items[0] = "no team";
	    for(int i = 1; i < items.length; i++){
	    	Map item = teamsName.get(i-1);
	    	items[i] = item.get("teamName");
	    }
		DefaultComboBoxModel model = new DefaultComboBoxModel(items);
		comboBox.setModel(model);
	}
	public  Object getSelectedTeamFromComboBox(){
		Object selectedItem = comboBox.getSelectedItem();
		return selectedItem;
	}
	public void setCoachAgrementPanelVisible(boolean x){
		 panelAgrement.setVisible(x);
	}
	public void addTeamComboboxItemListener(ItemListener l){
		 comboBox.addItemListener(l);
	}
	public void addCoachButtonActionListener(ActionListener l){
		btnAddCoach.addActionListener(l);
	}
	public JTextField getTextFieldCoachName() {
		return textFieldCoachName;
	}

	public void setTextFieldCoachName(JTextField textFieldCoachName) {
		this.textFieldCoachName = textFieldCoachName;
	}

	public JTextField getTextFieldCoachSurname() {
		return textFieldCoachSurname;
	}

	public void setTextFieldCoachSurname(JTextField textFieldCoachSurname) {
		this.textFieldCoachSurname = textFieldCoachSurname;
	}

	public JTextField getTextFieldCoachBirthdate() {
		return textFieldCoachBirthdate;
	}

	public void setTextFieldCoachBirthdate(JTextField textFieldCoachBirthdate) {
		this.textFieldCoachBirthdate = textFieldCoachBirthdate;
	}

	public JTextField getTextFieldCoachBirthplace() {
		return textFieldCoachBirthplace;
	}

	public void setTextFieldCoachBirthplace(JTextField textFieldCoachBirthplace) {
		this.textFieldCoachBirthplace = textFieldCoachBirthplace;
	}

	public JTextField getTextFieldCoachAgrement() {
		return textFieldCoachAgrement;
	}

	public void setTextFieldCoachAgrement(JTextField textFieldCoachAgrement) {
		this.textFieldCoachAgrement = textFieldCoachAgrement;
	}

	public JTextField getTextFieldAgrementFinish() {
		return textFieldAgrementFinish;
	}

	public void setTextFieldAgrementFinish(JTextField textFieldAgrementFinish) {
		this.textFieldAgrementFinish = textFieldAgrementFinish;
	}

	public JLabel getLblCoachName() {
		return lblCoachName;
	}

	public void setLblCoachName(JLabel lblCoachName) {
		this.lblCoachName = lblCoachName;
	}

	public JLabel getLblCoachSurname() {
		return lblCoachSurname;
	}

	public void setLblCoachSurname(JLabel lblCoachSurname) {
		this.lblCoachSurname = lblCoachSurname;
	}

	public JLabel getLblCoachBirthdate() {
		return lblCoachBirthdate;
	}

	public void setLblCoachBirthdate(JLabel lblCoachBirthdate) {
		this.lblCoachBirthdate = lblCoachBirthdate;
	}

	public JLabel getLblCoachBirthplace() {
		return lblCoachBirthplace;
	}

	public void setLblCoachBirthplace(JLabel lblCoachBirthplace) {
		this.lblCoachBirthplace = lblCoachBirthplace;
	}

	public JLabel getLblTeamSelect() {
		return lblTeamSelect;
	}

	public void setLblTeamSelect(JLabel lblTeamSelect) {
		this.lblTeamSelect = lblTeamSelect;
	}

	public JComboBox getComboBox() {
		return comboBox;
	}

	public void setComboBox(JComboBox comboBox) {
		this.comboBox = comboBox;
	}

	public JPanel getPanelAgrement() {
		return panelAgrement;
	}

	public void setPanelAgrement(JPanel panelAgrement) {
		this.panelAgrement = panelAgrement;
	}

	public JLabel getLblCoachAgrementLabel() {
		return lblCoachAgrementLabel;
	}

	public void setLblCoachAgrementLabel(JLabel lblCoachAgrementLabel) {
		this.lblCoachAgrementLabel = lblCoachAgrementLabel;
	}

	public JLabel getLblCoachAgrementFinish() {
		return lblCoachAgrementFinish;
	}

	public void setLblCoachAgrementFinish(JLabel lblCoachAgrementFinish) {
		this.lblCoachAgrementFinish = lblCoachAgrementFinish;
	}

	public JButton getBtnAddCoach() {
		return btnAddCoach;
	}

	public void setBtnAddCoach(JButton btnAddCoach) {
		this.btnAddCoach = btnAddCoach;
	}
	
	
}
